073 sorting of boxes based on weight part 2 of 3
好吧..所以让我们为这个逻辑编写代码,以便我将代码划分在不同的网络中 - 第一个表示启动/停止主传送带,其中主传送带和所有其他传送带。
Alright ..so let's write the code for this logic so I'm going to divide the code in different networks - The first one say start/stop main conveyor where main conveyor and all the other conveyors.
其次是数箱子...
Second is counting the boxes...
第三步是将值存储在数组中。
third is storing the value in array.
第四是数箱子。
Fourth is counting the boxes..
我们正在数不同的盒子吗?
there are different boxes we are counting?
所以启动/停止主输送机..所以我要做的是用这个启动按钮在这里用这个绿色按钮我将启动这个输送机,称重输送机和这些滚筒上的所有输送机向前方向好所以让我们了解驱动程序中这些输入/输出的标记..
So the start/stop main conveyor..so what I'm going to do is with this start button here with this green button I'm going to start this conveyor, weighing conveyor and these all conveyors on the rollers in the forward direction ok so let's understand the tagging of these input/outputs in our driver ..
所以如果我转到我的文件并转到驱动程序,您会看到这是我对该软件的接线......
so if I go to my File and go to Drivers you will see this is my wiring for this software ...
我将使用 S7-1200 PLC 控制器,我不使用模拟。
I'm going to using S7-1200 PLC controllers I'm not using simulations..
我正在使用真实控制器(PLC),所以你可以在 I0.0 中看到它。
I'm using the real controller (PLC) so you can see that in I0.0 ..
让我这样做 I0.0 是第一个传感器,在这里你可以看到文本后面的蓝色传感器......
let me do it this way I0.0 is the first sensor which is here you can see this blue sensor behind the text ...
这是漫射传感器 6,所以我的主传送带的第一个传感器连接到 I0.0,好吧,我在我的逻辑中使用了相同的标签,所以我稍后会涉及到......
this is diffuse sensor 6 so my first sensor of the main conveyor is connected to I0.0, Alright I have used the same tag in my logic so I will relate that later on...
那么你就有了“大规模”..
then you have 'At scale'..
现在您可以看到“按比例”就是这个如果您看到这个传感器,这是“按比例”传感器,因为它安装在秤上然后您有“在出口左侧”,所以“在出口左侧”在这里,这是在出口左侧,传感器位于左侧出口输送机处,然后传感器位于右侧出口输送机处,传感器位于出口输送机前侧,因此我们有三个传感器。
now you can see that 'At scale' is this one if you see this sensor this is 'At scale' sensor because it is mounted on the weighing scale then you have 'At exit left' so 'At exit left' is here this is your 'At exit left the sensor at the exit conveyor of the left side then you have sensor at the exit conveyor of right side and you have sensor at the exit conveyor front side so we have three sensor.
我们有“在出口处”、“在出口右侧”、“在出口前面”..好吧,那么您有启动/停止重置按钮,这些按钮将执行 I1.0、I1.1、I1.2 ..
We have 'At exit', 'At exit right', 'At exit front' ..Alright then you have start/stop reset buttons which are going to do I1.0, I1.1, I1.2 ..
这三个按钮在我们的面板中,好吧......
these three buttons are in our panel ok ...
在这里开始、停止、重置。
here start, stop, reset.
我现在正在使用这三个按钮,如果你在这里看到 ID100,这是一个寄存器,我可以在其中获取重量值...
I'm using these three buttons now if you see here ID100 this is a register where I'm getting the weight value the...
重量值,这意味着它不是以千克为单位,而是以电压为单位,因为我们的传感器获得 0 到 10 伏的电压,因此来自称重秤的 0 到 10 伏的电压连接到 ID100,这是寻址。
value of weight it means it's not coming in kg it's coming in voltage because our sensor is getting 0 to 10 volts so 0 to 10 volts which is coming from the weighing scale is connected to ID100 this is the addressing..
让我们看看输出 Q0.0(入口传送带)Q0.1(向前发送)所以入口传送带就是这个......
let's see for the output we have Q0.0 (Entry Conveyor) Q0.1 (send forward) so entry conveyor is this one...
这是我的主要入口传送带。
this is my main entry conveyor.
“向前发送”意味着该滚轮将向前运行......好吧向前方向......
'Send forward' means this roller will run in the forward direction..alright forward direction..
这是“向前发送”,您可以看到这里有“向左发送”、“向右发送”。
this is the 'Send forward' you can see that here then we have 'Send left', 'Send right'..
这意味着这些滚筒将在 Q0.3 处转向左侧,在 Q0.4 处转向右侧,那么 Q0.5 是“左输送机”,因此该输送机将在 Q0.5 处运行。
this means these rollers will turn into left side by Q0.3 and right side by Q0.4 then you have Q0.5 is 'Left conveyor' so this conveyor is going to run by Q0.5.
Q0.6 是“右输送机”,Q0.7 是“负载秤”。
Q0.6 is 'Right conveyor' , Q0.7 is 'Load scale'..
因为秤也在运行..秤上有一个传送带也在运行,因此连接到 Q0.7..
because the scale is also running..there is a conveyor on the weighing scale which is also running so that is connected a Q0.7..
在数字“double int”的输出中,我们有 QD100,它是一个权重。
In the output of digital 'double int' we have QD100 which is a weight..
所以这就是重量的值......
so this is the value of weight ...
好吧抱歉,这是这个值不是这个重量..这个值是重量的显示..?
okay sorry this is this value is not this weight..this value is the display for the weight..?
所以如果你看到这里..
So if you see here ..
这里我们在数字显示中显示了重量值?
here we have the value of weight in the numeric display?
这是连接到 QD100 的输出,然后您有“左计数”、“右计数”和“前计数”。
That is the output connected to QD100 then you have 'left count', 'right count' and 'forward count'.
这三个输出显示在此处“左计数”、“前计数”和“右计数”。所以三个独立的寄存器,因此如果您对此标记有任何疑问,可以给我写一条评论,否则我认为这是我们最简单的一个传感器、按钮和秤,所有这些传送带都是数字显示器。
These three outputs are displays here 'left count', 'forward count' and 'right count' ..So three independent registers so if you have any doubt about this tagging you can write me a comment otherwise I think it's the easiest one we have sensors, buttons and the weighing scale, all these conveyors here and these are the numeric displays..
好吧,让我们看看第一步,..
Alright so let's see the first step,..
所以我想要的第一步是我们要启动所有传送带..
So the first step I want is we want to start all the conveyors..
使用这个按钮,所以如果你回到这里,我要做的就是这里的这个按钮......
using this button so what I'm going to do is this button here if you go back here...
让我明确一下这个按钮是 I1.0...
let me make it clear this button is I1.0...
所以我要采用常开输入 I1.0 是我的开始按钮......
so I'm going to take normally open input I1.0 is my start button ...
标签(*评论)已经在那里我要设置传送带..
tag (*comment) is already there I'm going to set the conveyors..
所以很容易你可以在这里看到标记,我将使用 set 命令,所以第一个是入口传送带,Q0.0 这是设置的,然后我将并行设置其他输出,当然可能还有其他输出编写逻辑的方法也可以进行锁存,因此完全取决于您想要如何对 PLC 进行编程?
so it's very easy you can see that tagging here and I'm going to use set command so the first one is entry conveyor, Q0.0 this is set and then I'm going to set parallelly other outputs of course there could be other ways to write the logic you can do latching as well so it's totally up to you how you want to program program your PLC?
好吧,我们不会设置 Q0.2,因为这些是我们必须通过称重逻辑设置的滚筒,因此我们将仅设置输送机 Q0.4、Q0.5、Q0.6 和 Q0.7 ..so Q0 .4 Q0.5 ...
alright we are going we are not going to set Q0.2 because those are the rollers which we have to set by weighing logic so we will set conveyors only Q0.4, Q0.5 Q0.6 and Q0.7 ..so Q0.4 Q0.5 ...
Q0.6 Q0.7 ..
Q0.6 Q0.7 ..
所以我们有所有必要的输出由开始按钮锁定,所以但是对于开始我还需要一个停止按钮......
so we have all the necessary outputs latched by the start button so but with Start I also need a stop button...
但停在这里是我的“NC”(常闭)按钮,所以我将在这里使用 NC 我希望您知道这是我们前几课中的内容。
let's but Stop here is my 'NC' (Normally closed) button so I'll take NC here I hope you know that is in our first few lessons..
所以我要选I1.1..
so I'm going to take I1.1..
因为我正在使用重置命令,这就是我使用 NC 的原因......
because I'm using reset command that's why I'm using the NC ...
所以这里我需要重置。
so here I need reset.
我将使用重置字段,因为我可以将所有输出重置在一起,因此这将从 Q0.0 开始为 Q0.0,我们最多有 8 个输出...所以我在这里放 8 个,好吗?
I'll use reset field, because I can reset all the outputs together so this will be Q0.0 starting from Q0.0, we have up to 8 outputs ...so I put eight here okay?
好吧酷..
Alright cool ..
所以这是一个开始/停止逻辑..
so this is a start/stop logic..
让我们下载到 PLC 中,然后在工厂 I/O 中查看结果...
let's download into our PLC and let's see the result in our Factory I/O...
所以逻辑已下载让我上网...好吧...
so the logic is downloaded let me go online ...okay...
那么当我们回去检查一切是否正常时?
so when we go back and just check if everything is ok ?
按“开始”后,我的传送带正在运行,但有一个问题,这不是前进!?
By pressing 'Start' my conveyors are running but there is a problem this is not forward !?
让我看看有什么问题..
Let me see what's the problem..
Q0.1...
Q0.1...
滚轮向前..Q0.2和Q0.3是左和右。
roller forward ..Q0.2 and Q0.3 is left and right.
这些都没有设置。
Those are not SET.
好吧,现在没事了......所以你会看到箱子只会向前移动,没有分拣滚筒向前运行。
okay now it's okay ...so you'll see the boxes will just go forward there is no sorting rollers are running forward..
什么都没发生?
nothing is happening?
但您不必担心,因为我们会对其进行排序。
but you don't have to worry because we are going to sort it.
这只是为了检查一切是否正常?
This is just to check if everything is fine?
所有输送机都在运行。
All the conveyors are running.
是的?
Yeah?
一切正常 ..
Everything is okay ..
这样你就可以从这里停止所有传送带然后重新启动,好吗?
so you can stop all the conveyors from here and you can start it again okay?
这是运行传送带的逻辑的第一部分。
So this is the first part of logic to run the conveyors.
好简单?
Very easy?
现在让我们进入第二部分我必须离线..
Now let's go to the second part I have to go offline..
好吧,第二个是我们必须计算盒子的数量,现在我们有三种不同类型的盒子,我们将把这三个盒子存储在一个由三个元素组成的数组中。
Alright, second is we have to count the boxes now here we have three different types of boxes okay and we are going to store these three boxes in an array of three elements.
好吧,因为我们将存储..
Alright because we will store the..
第一个元素数组中第一个框的信息...
information of first box in the array of first element...
无论您说什么,第一个数组的元素以及数组第二个元素中第二个框的信息和数组第三个元素中第三个框的信息。
element of first array whatever you say and the information of second box in the second element of array and information of third box in the third element of array.
好的,因为我们要排列。
Okay, because we are going to array.
所以要计算我要使用的盒子..
So to count the Boxes I'm going to use ..
最初柜台好吗?
initially the counter Alright?
所以在这里我将使用这个漫射传感器的下降沿或上升沿来计算盒子的数量,好吗?
so here I'm going to count the boxes using the falling edge or the rising edge of this diffuse sensor okay?
我更喜欢使用下降沿,这样当盒子离开这部分时,您希望该盒子被正确计数,所以让我们使用它的下降沿并将其交给计数器,所以在这里我将使用常开触点。 。
I prefer to use the falling edge so that when the box leaves this part, then you want that box to be counted okay so let's use it's falling edge and give it to the counter so here I'm going to use normally open contact...
将其更改为下降沿..
change it to falling edge..
现在这个漫反射传感器的传感器是 I0.0,我可以在这里向您展示 I0.0,所以我将采用 I0.0,我将采用它的内存位,抱歉,内存位 M0.0!好吧..
now this diffuse sensor the sensor was I0.0, I can show you here I0.0, so I will take I0.0 and I'm going to take its memory bit sorry memory bit M0.0 !Alright..
这就是我之前给出的下降沿标签,所以有了这个下降沿,我将运行计数器,好吗?
so that's my falling edge tag which was previously given so with this falling edge I'm going to run the counter okay?
所以你可以从你的指示中获取计数器......
So counter you can take from your instructions...
去柜台..
go to counter ..
记一下(CTU)这个你可以轻松记下吗?
take count up (CTU) this you can take easily?
这是数据库..
This is the database..
单击“确定”?
click OK?
现在最好有一个数据库来存储过程值或预设值。
it's good to have a database now the process value or the preset value.
这是预设值..
This is the preset value..
我们需要在这里放 3,因为我们现在正在数 3 个盒子,这是一个计数值。
we need to put here 3 because we're counting 3 boxes now this is a count value..
你想要..
you want to..
如果您想将此值存储在某处,以便我们可以使用您刚刚创建的计数器数据库,请单击此数据库,您可以单击“Database_0”,这是一个计数值,因此有一个数据库,其中计数计数器的当前值正在存储,这是预设值好吗?
if you want to store this value somewhere so we can use the counter database which you have just created so click on this one and you can click 'Database_0' and this is a count value so there's a database where the count current value of the counter is being stored and this is a preset value ok?
这就是您现在进行 CTU 计数以重置计数器的方式 我希望该计数器在第三个框之后自动重置,好吗?
So this is how you have made made a CTU count up now to reset the counter I want this counter to be reset automatically after third box okay?
因此,在第三个框之外,我们将将此计数器重置为 3 或 3 或大于 3,因此我将使用比较框..
So off the third box we weill reset this counter at 3 or 3 or greater than 3 so I'm going to use the compare box ..
您可以在这里找到比较命令..
compare command which you can find here..
不是这里“比较”是的“相当于”..
not here 'Compare' yeah 'equivalent to'..
我将使用“等于”,并且我希望如果计数器值为 3 或大于 3,则应重置它们。
I'm going to use 'equivalent to' and I want if the counter value is 3 or greater than 3 they should be reset..
现在要比较的值与这里的值相同......
now the values which are going to compare is the same value which is here ...
所以这是同一个标签?
so this is the same tag?
所以我将使用“计数器数据库 0”..
So I'm going to use 'Counter database 0'..
现在的当前值,如果该值等于“3”,或者我也可以使用“大于等于”,但我认为这可以吗?
current value now if the value is equivalent to '3' or I can also use 'Greater than equivalent to' but I think this is okay?
计数器将被重置..好吧,让我们检查这部分逻辑来计数 3 个盒子,并在值为 3 时自动重置计数器...
The counter will be reset ..okay so let's check this part of the logic to count 3 boxes and resetting the counter automatically if the value is 3...
因为当计数值为0时..
because when the count value is 0..
我们将存储第一个元素...
we will store the first element...
当计数值为1时...
when the count value is 1...
我们将存储第二个元素...当当前值为 2 时,我们将存储第三个元素...当计数值为 4 时...它将重置并再次存储第一个元素?
we will store the second element ...when the current value is 2, we will store the third element ...and when the count value is 4...it will reset and it will again store the first element?
稍后当我们制作数组时我们就会明白......
We will understand that later when we going to make the array...
在这里,您只需了解您只是在计算盒子,而我们只是在每三个盒子后重置盒子......好吗?
here you just have to understand you are just counting the boxes and we are just resetting the box after every third box ..ok?
所以让我们再次..启动传送带..计数值你可以看到它是1,现在第二个盒子来了,这是两个..
So let's again ..starting the conveyor ..count value you can see it's 1 now the second box is coming that's two..
现在第三个盒子..
now third box..
零 好的,所以我们有值 0,然后我们有值 1,然后我们有值 2。
zero okay so we have the value of zero and then we have value 1 and then we have value 2.
所以我们有 3 个值 0、1 和 1。 2 我们将使用这三个值来移动特定盒子的重量......
So we have 3 values 0, 1 & 2 we are going to use these three values to move the weight of the particular box...
第一个盒子位于“计数 0”处...
of the first box which is at 'Count 0'...
位于“计数 1”的第二个盒子和位于“计数 2”的第三个盒子...
of the second box which is at 'Count 1' and of the third box which is at 'Count 2'...
那么这意味着我们将在 3 个数组元素中存储 3 个值?
so it means we are going to store 3 values in 3 array elements?
因为数组中的值是从 0 开始的好吗?
Because in array the values are from 0 okay?
数组元素 0, 1, 2 & 3.
Array element 0, 1, 2 & 3.
那么如何做到这一点呢?
So how to do that?
这是关于计数部分的。
So this was about the counting part..
现在我们将转向“网络 3”..
now we will move to the 'Network 3' ..
现在好'网络3..
ok now 'Network 3 ..
我们更喜欢在SCL中制作。
we prefer to make in SCL.
所以我有一个块..
So I have a block ..
块 1 是 FC1,这个块是我通过 -> 程序 -> 新块创建的,然后是 SCL 块..这个函数和 SCL?
block 1 which is FC1 and this block I have created by ->Program ->New block and then SCL block..this function and SCL?
在来到这个区块之前我已经为你创建好了..我还想告诉你我们已经做了一个数据库?
I have already created for you so before coming to this block..I would also like to tell you that we have made a database?
现在你怎样才能做到这一点?
Now how you can do that?
您只需转到“添加新块”即可。
You just have to go to 'Add new block'..
单击“数据库”,然后单击“确定”?
click 'Database' and click OK?
然后你就有了一个数据库,这个数据库我已经做了一个数组。
Then you have a database and this database I have made an array.
我会再为你做一次..
I will make it again for you..
好吧,那么我们要做的是?
okay so what we have to do is?
这是自动创建一个变量。
This is the automatically here just create a variable..
让我们说 - 重量..
let's says - Weight..
现在我想把这个变量变成数组?
now this variable I want to be array?
因此,您可以输入 array 或从下面的菜单中找到它,然后单击此...
So you can type array or find it from the menu down below and click on this one...
现在在该区域中,我们将存储重量信息,该信息是真实格式的,因此您必须选择的数据类型是“真实”?
now in the area we are going to store the information of weight, which is in real format so the datatype you have to select is 'real'?
哦抱歉 ..
Okay sorry ..
现在你必须提到这个数组中需要多少元素,我们需要三个元素,所以我可以说它 0, 1 & 2 所以我有 3 个元素好吗?
and now you have to mention how much elements do you need in this array we need three elements so I can say it 0, 1 & 2 so I have 3 elements okay?
所以如果你只是拖到这里..
So if you just drag down here..
哦对不起...
oh sorry...
不在这里,是的,你有数组的三个元素?
not here yeah you have three elements of array?
元素 0...
Element 0...
元素 1 和元素 2 - 在这个重量数据库中好吗?
Element 1 and Element 2 - in this weight database okay?
稍后我们将向您展示如何使用它,所以现在我们在这里有这个代码......
We'll show you how we can use that later on so now we have this code here...
让我这个离线..
let me this goes offline..
好的,我们已经为您定义了一些输入和输出。
okay so we have defined some inputs and output all ready for you.
让我们看看这些是什么..
Let's see what are these..
首先是计数好吧..Count 被声明为“int”输入,现在这个计数输入意味着我们将读取计数器的“计数”好吗?
first is the count okay..Count is declared as 'int' input now this count input means we are going to read the 'counts' of the counter okay?
我们来看看计数器的计数是0还是1还是2好吗?
we will see if the count of the counter is 0 or 1 or 2 okay?
所以我会写这个评论 - '计数器计数' 或者你也可以写'计数器当前计数' 好吧,现在接下来是重量......现在这是来自秤的重量,所以我会写评论 -来自传感器的“传感器”,然后您就有“食谱编号”,我们稍后会回来。
So I will put this comment - 'Counts of counter' or you can also write 'present count of counter' Okay all right now next is the weight ...now this is the weight coming from the weighing scale so I would write comment- 'Sensor' coming from the sensor then you have 'Recipe number' this we will come back later..
所以让我把它删除,我不知道你有“按比例”,现在我想要的是我们这里有一个“按比例”传感器。
so let me remove it I don't know then you have 'At scale' now what I want is we have a sensor here 'At scale'..
我希望当盒子处于传感器范围内时记录重量值,为什么我们要这样做?..
I want the value of weight to be recorded when the box is in the range of sensor and why we are doing that ?..
因为当您注意到箱子何时在该传送带上行进时,除非箱子完全在该传送带上......
because when you notice when the box is traveling on this conveyor unless the box is totally on this conveyor...
除非盒子被转移到这个传送带上。
unless the box is transferred to this conveyor..
我们将无法获得准确的值..
we will not get the accurate value..
所以这个传感器的设计和安装方式是这样的:当传感器读取盒子信号时,传感器注意到有盒子......
so this sensor is planned and is installed in such a way that when the sensor reads the box signal and the sensor notice that there is the box...
盒子已经完全放在秤上了吗?
the box is already fully on this weighing scale?
这就是大规模使用传感器的想法。
That's the idea of having the sensor at scale.
所以我们有这个“按比例”和评论,你知道你可以写..在..
So we have this 'At scale' and at comment which is you know you can write ..on the..
在传感器上..在秤传感器上。
on the sensor ..on the weighing scale sensor.
好吧,现在在输出中我们有左和右......
Alright, now in the outputs we have left and right ...
现在左右是这些滚轮 - 向左发送和向右发送我可以输入滚轮...
now this left and right are these these rollers - Send left and send right I can type rollers...
对于滚筒。
for the rollers.
称重显示适用于面板显示,现在在面板显示中您会注意到...
Weighing display is for the panel display now in the panel display you will notice...
哎呀!?
oops!?
是的,在面板显示中我们使用了“int”,好吧我们必须显示该值,但这里不是......
Yeah in the panel display we have used 'int' okay we have to display the value and here it's not...
这是……这是“双精度”……
it's ...it's 'double int'...
double int 因为如果你去驱动程序并且面板显示是“double int-DINT”,那么你必须匹配..
double int because if you go to the driver and the panel display is 'double int- DINT' okay so you have to match the..
匹配新的数据类型是非常必要的,这些都是布尔值,因为这个布尔值只有开和关。
match new data type it's very necessary and these are Boolean because this Boolean is only On and OFF.
因此,“向右发送”和“向左发送”是布尔值,类似地,“按比例”传感器打开和关闭,这就是布尔值。
So 'send right' and 'send left' is Boolean similarly here 'at scale' the sensor was on and off and that's Boolean.
体重秤是真实的,所以它是真实的,计数是计数器的计数......
Weighing scale was real so it was real and count was the number of counts by a counter ...
这就是为什么它在这里是“int”?
that's why it is 'int' here ?
好吧,现在我们还有另一个..
Okay, now we have another another ..
array 这里我们使用了数组 temp ..
array here we have used the array temp ..
好吧,现在我们为什么要使用 3 个临时数组?
okay temp array of 3 now why we are using it?
当我要编写代码时我会向你解释这只是为了存储权重值好吗?
I will explain you when I'm going to make the code this is just to store the value of weight okay?
因此,因为我们需要在代码中存储值,所以它们会将值存储在全局数据库中,因此要在代码中使用数组,我们必须在此处使用“temp”。
So because we need to store the value in the code then they will store the value in the global database here so to use an array in the code we have to use 'temp' here..
这将帮助我们轻松地建立逻辑,然后是排序六数组,我稍后会谈到这是使用食谱进行排序?
this will help us to make the logic easily and then comes the sorting six array which I will come to later this is for sorting using recipes?
到目前为止,您已经有了这些数据类型。
So far you have these datatypes.
好吧,现在是代码了..现在您可能正在考虑如何编写代码?
Alright, now comes the code ..now you might be thinking how to make the code?
因此,当您要定义操作步骤时,它总是会出现......
So it always comes when you're going to define your steps of operation...
因此,如果您知道如何执行步骤,那么代码创意就会自动出现在您的脑海中吗?
so if you know how to make your steps the code idea will automatically come in your mind?
因此,您必须遵循的第一步..现在,如果您注意到第一个框出现在这里,那么让我们进入演示文稿。
So the first steps which you have to follow ..let's go to the presentation Now if you notice here when the first box comes here..
我只会做一个小盒子..
I will just make a small box..
什么尺寸都没关系..
doesn't matter what size ..
什么形状..
what shape..
所以如果你有第一个盒子,让我放一些橙色!?
so if you have the first box let me put some color orange !?
在这里,当你在这里拥有第一个盒子时......
Here so when you have the first box here...
现在我们这里有传感器..
now we have the sensor here..
我们有一个传感器可以计算即将到来的盒子数量,好吗?
we have a sensor which is going to count the the coming count of the boxes ok?
因此,当您在这里拥有第一个盒子并且此时盒子到达时,我们就有了一个“按比例”的传感器,好吗?
So when you have the first box here and when the box comes at this point, we have a sensor 'At scale' okay?
所以如果你回到这里并回到这里......
So if you come back here and come back here...
让我运行逻辑?
let me run the Logic ?
是的,那么让我们从这个真实环境中了解代码的设计?
Yeah so let's understand the designing of code from this real environment?
我们想记录体重..
We want to record the weight ..
当该传感器打开时。
when this sensor is ON.
好吧,此时我们再次想要记录该值,好吗?
Okay once again at this point we want to record the value okay?
所以我们要做的是,我们必须在“按比例”很高、“按比例”为 1 的那一刻开始编写代码,所以让我在这里编写代码,这样当比例很高时......
So what we are doing is we have to start writing the code at that instant when 'At scale' is high when 'At scale' is 1 okay so let me just make it here so when scale is high...
现在“按比例”是这里“按比例”的布尔值,所以我会写如果“按比例”很高,即“1”,那么会发生什么?
now 'At scale' is the Boolean here 'At scale' so i will write if 'At scale' is high which is '1' then what should happen?
然后我们要记录重量..
Then we want to record the weight ..
但是哪里?
but where?
..在数组中可以在数组的第一个元素中吗?
..in the array okay in the first element of the array?
所以要做到这一点..
So to do that ..
我们要做的是..我们必须移动权重的值..
what we have to do is ..we have to move the value of weight ..
这是重量..
this is the weight ..
这是输入。
this is the input.
理解!?
Understand!?
这是我们从传感器获得的输入,它将进入我的数组的临时值。
This is the input which we are getting from the sensor this will go into the temporary value of my array.
可以,然后呢 ..
Okay so ..
啊,这个临时数组将移至左侧,因为我们正在将值从右向左移动......
Ahh This temporary array will come to the left because we are moving the value from right to left...
所以我现在要写“temp”,我希望你明白这一点,如果我在这里放 0 并写一些类似...weight 好的,会发生什么,权重值将转到临时(temp)的第一个元素好的?
so I'm going to write 'temp' now I want you to understand this thing that if I put 0 here and write something like ...weight okay what will happen the weight value will go to the first element of temporary (temp) okay?
如果我写...
If I write...
这将转到临时(temp)的第二个元素,好吗?
this will go to the second element of temporary (temp) okay?
如果我写..
If I write ..
这会去..
this will go..
哦对不起...
Oh sorry...
这会转到第三个元素吗?
this will go to the third element?
但我们不会一遍又一遍地写所有这些元素 0、1 和 0。 2 相反,我们可以借助我们定义的计数器吗?
But we are not going to write all these elements over and over again that 0, 1 & 2 instead we can take the help of the counter which we have defined?
您知道我们在这里设计了一个计数器,并且我们正在 CV 中获取计数器的值,好吗?
You know we have designed a counter here and we are getting the value of counters in the CV okay?
我们可以从 CV 中获取这个值,即 0、1 和 0。 2 我们可以在这里使用它 0, 1 & 2 好吗?
We can take this value from the CV which is coming 0, 1 & 2 and we can utilize it here 0, 1 & 2 okay?
我希望你明白这一点。
I hope you understand this point.
所以我将使用什么来代替这个常量 0, 1 & 2..
So what I'm going to use instead of this constant 0, 1 & 2..
我将在这里采用一个变量“count”,我们在这里定义了“当前计数器计数”,所以我将采用“count”,那么如果计数器为 0 会发生什么..
I will take here a variable which was 'count' we have defined here 'present count of counters' so I'm going to take 'count' so what will happen if the counter is 0..
计数器为 0...
the counter is 0...
权重的第一个值将移入(*数组的第一个元素)...如果计数器为 1..
the first value of weight will move in the (*first element of array) ...if counter is 1..
如果计数器为 2,权重的第二个值将移动到该数组的第二个元素中。当前盒子的权重将移动到数组的第三个元素中,并且它将继续重复。
second value of weight will move into the second element of this array, if counter is 2..the weight of the current box will move into third element of array and it will keep on repeating..
好吧?
Alright?
这就是你的阵列的工作原理!?
So this is how your array will work!?
所以这就像……只有当刻度为“1”时才会发生,这意味着它只能在传感器较高时记录值?
So this is like when...this would only happen if the scale is '1' it means it can only record the values when the sensor is high?
好吧,那么我们就停下来...
okay so we'll stop...
我们将停止循环..这个命令在这里?
we'll stop the loop..this command here?
如果您只是想了解存储值的逻辑,我们可以尝试一下。
If you just want to understand this logic of storing the value we can just take a trial of that..
在继续之前?
before proceeding further?
好吧,让我们进入 main,将我们的功能代码拖到这里..
Okay let's go to main and let's drag our functional code here ..
好吧好吧,让我们再次阻止..
Alright Okay let's go back to block again..
到目前为止,我们还没有使用左、右和其他值,所以我可以删除它。
so far we are not using left, right and other values so I can delete it..
'左边'..
'left'..
“正确”只是我们的滚轮..
'right' are just our rollers..
我们没有使用“称重显示器”...
'weighing display' we are not using...
我们正在使用“温度”...我们正在使用“计数”,我们正在使用“重量”...
'Temp' we are using ..'count' we are using and 'weight' we're using...
“按比例”,我们使用重量“计数”,我认为这是四个变量!?
'At scale' we are using weight 'count' and i think these are the four variables!?
是的,让我们再次转到“main”更新块吗?
yeah let's go to 'main' again update the block?
好吧,现在计数是我的计数器的计数..
all right, now the count is to count of my counter..
所以我就...
so I will just ...
选择我的柜台 ->数据库 ..
select my counter -> database ..
将计数放在这里..重量直接来自我的 PLC,这是“ID100”,所以我可以放在这里,因为这是直接来自 PLC 的值——“按比例”,这意味着传感器按比例的布尔值,这如果我们注意到连接在 I0.1 处...
Put the count here..weight is coming directly from my PLC this is 'ID100' so I can put here because this is the value coming directly from the PLC --'At scale' which means the Boolean of the sensor at scale and this at scale if we notice is connected at I0.1...
现在“大规模”..
now 'At scale'..
我们想要的是我想使用它的脉搏......
what do we want is I want to use its pulse...
我不想使用传感器的整个值,因为它可能会多次运行我的数组..我只想使用它的边缘..
I don't want to use as whole value of sensor because maybe it will run my array multiple times..I just want to use its edge ..
这个传感器的“上升沿”所以我要使用的是..
'the rising edge' of this sensor so what I'm going to use is..
我将转到位逻辑并获取上升沿并将其连接在这里,在这里我将输入 I0.1..
I will go to bit logic and take the rising edge and connect it here and here I will type I0.1..
这是我的传感器,在这里我可以采取 M0.1 这是我们的上升沿标签...
this is my sensor and here I can take M0.1 This is our rising edge tag...
&我可以写这个 - 重命名标签 - '入口传感器' 好吧......让我们下来......
& this I can write - rename tag - 'Entry sensor' Alright so..let's down....
还好,现在这个温度...
okay temp now this temp...
所以这是我们得到的权重值,让我们把这个值放入权重数据库中,我们在这里创建了权重数据库,再次..数组实数的三个元素。
so this is the value of the weight which we are getting and let's put this value into the weight database okay, which we have created here the weight database is the again..three elements of array real.
所以回到主目录并输入 Weight.weight...
So go back to main and put Weight.weight...
让我看看出了什么问题?
let me see what's what's wrong ?
好吧,我必须再次确保这是 3,因为这里的值应该是 0、1、2 - 是的,转到主逻辑...更新 现在一切都正常了吗?
okay I have to make sure this is three again because the values here are 0, 1, 2 should be - yeah go to main logic ...update Now everything is ok?
是的,就是这样?
so yeah that's it ?
这就是我们存储值的方式,让我们下载并查看结果?
This is how we are storing the value let's download and see the results ?
初始化-加载 太棒了!?
Initialize -Load Great!?
现在我们的 PLC 中已经包含了所有内容。
So now we have everything inside our PLC.
让我们监视它并查看数据库中的权重值......
Let's monitor it and see the values of weight in our database...
所以要监控来到这里的重量..
so to monitor the weight which is coming here..
我可以打开重量,或者我也可以去观察表,我可以在这里定义这是..
I can open the weight or I can also go to watch table and I can define here this is ..
好的,这是为重量定义的标签...这是计数器。
OK this is the tag defined for the weight ...this is the counter .
我们的计数器为零,所以在这里我可以读到......
Our counter is zero so here I can read ...
让我选择我的体重...
let me select my weight ...
是的,重量为 0,并且...我可以将其扩展一和二..
that'll be yeah Weight 0, and ...I can extend it one and two..
这是我的体重,在这里我可以使用我的计数器,以便我们了解发生了什么?
this is my weight and here I can use my counter so that we can understand what's going on?
-计数值..
-Count Value..
好吧好吧?
Alright okay?
所以这是“计数值 0”、“计数值 1”,因此当计数器值为 1 时,这里的权重...
So this is the 'Count value 0', 'Count value 1' so when the Counter value is 1, this weight which is here...
将存储在这里...
will be stored here ...
当计数值为 2 时,该重量..
when count values is 2 this weight..
将被存储在这里..
will be stored here..
当当前值为0时,此处将存储当前重量。
when the current value is 0, the weight current weight will be store here.
所以你可以看到...
So you can see that ...
计数值为 1 该重量将存储在这里..
the count value is 1 this weight will be stored here..
所以这个中型盒子 5 公斤或 5.0 这又是 4.9 存储在这里...所以现在你可以看到这个数组正在重置并且它存储了最多 3 个盒子的重量..
so this medium box 5 kg or 5.0 This was 4.9 again that is stored here ...so now you can see that this array is getting reset and it is storing the weight of upto 3 boxes ..
只需注意这里发生的事情一分钟,这样您就可以意识到发生了什么这是 2 ..
just notice what's happening here for a minute so that you can realize what's happening This is 2 ..
所以这是存储在元素 1 处,而不是元素 2 处,因为该元素 0 在这里,1 在这里,2 在这里,所以在 1 处..
so this is storing at element 1, not at element 2 because this element 0 is here, 1 is here, 2 is here so at 1..
该值在 2 处出现 该值在此处出现..
this value comes here at 2 this value comes here..
当 0 时,该值出现在这里..
at 0 this value comes here..
好吧,所以我希望到目前为止..
okay so I hope by this far..
你已经明白我们得到了 3 个值好吗?
you have understood that we are getting 3 values okay?
如果你去你的街区...
If you go to your block...
我不确定我是否也可以模拟它..
I'm not sure if I can simulate it as well ..
有错误吗?
Some error?
好吧,这是关于如何...我们可以阻止它如何将权重值存储在数组的三个不同元素中?...
okay so this was about how to...can we stop it How to store the value of weight in three different elements of array?..
好吧?
alright?
现在一旦我们有了这个值..
now once we have this value ..
我们所要做的就是现在转动滚轴刀片这个滚轴..
all we have to do is we just have to now turn the roller blade this rollers ..
向右和向左,所以我们必须遵循的第一个方法是大盒子将走向直线,这意味着没有一个滚筒在工作,它将走向直线,所以如果有一个大盒子,我们将重置左右两侧好吧,那么我们会写什么?
into right and left so the first recipe which we have to follow was the large boxes will go to straight which means none of the rollers are working it's going to the straight so we are going to reset both right and left if there is a large box okay so What we will write?
现在在这种情况下你必须读取 count 的值好吗?
Now in this case you have to read the value of count okay?
所以我们会写 If temp...
So we will write If temp...
我现在可以将这个复制到大盒子里。
I can may be copy this one now for the large box..
我想再次向您展示即将到来的值是 7.5 所以我们将采用 7-8 的范围,因为有时值是 7.4、7.5..
I want to show you again the values coming is 7.5 So we will take a range of 7-8 because sometimes the values are 7.4, 7.5..
7.9 所以就取七到八之间的范围吧,这可能是......
7.9 so just take a range between seven and eight okay this could be...
这是可以选择的,所以大于 7.0 这是一个“与逻辑”,两个条件都可以,这里它小于 8.0,这意味着当值在 7 和 8 之间时会发生什么?
it is okay choice so greater than 7.0 this is an 'And logic' and two conditions okay and here it's less than 8.0 which means when the value is between 7 and 8 what should happen?
然后我们希望*左右滚轮都关闭,好吗?
and then we want both the *left and right rollers to be OFF okay?
现在是输出部分,我们将左右两个输出。
Now comes the part for the output we will take two outputs left and right..
在这里我可以写左滚轮右滚轮..
in this I can write left roller right roller..
两者都是布尔值,所以左滚轮为零,右滚轮也为零......
both are Boolean okay so then left roller is zero also right roller is zero...
这意味着两者都将被重置 - End_IF。
which means both will be reset - End_IF.
好吧,这就是条件......现在是第二种情况......对于较小的盒子......我的意思是让我们采取一个中等的......
okay this is the condition ...now the second case for ..for the smaller boxes..I mean let's take a medium one..
当值为 4.5 和 5.5 时..
When the value is 4.5 and 5.5 ..
当值在 4.5 和 5.5 之间时,我们取 0.5 的边距,我们想向右打开滚轮,好吧,所以让我复制这个,以便在值大于 4.5 时变得容易,正确吗!?
let's take the margin of 0.5 when the value is between 4.5 and 5.5 we want to turn on roller towards right okay so let me copy this one to make it easy when the value is greater than 4.5 correct!?
因为medium box的值是5并且小于5.5,所以我也可以写注释“medium box”..以避免混淆..
because the value of medium box was 5 and less than 5.5 here I can also write the comments 'medium box' ..to avoid confusion..
这是一个大盒子。
this is a large box here..
“存储盒子信息”好吧好吧,当它是我们想要的中号盒子时 - 滚轮到“右” - 为“开”和“左” - 为“关” - 所以右滚轮将是“开”和“左”为“关闭”,则滚轮将向右移动..正确!?
'Storing box information' okay okay when it's the medium box we want- rollers to the 'right' - to be 'ON' and 'left' - to be 'OFF' - so right rollers will be 'ON' and 'left' is 'OFF' then the rollers will move towards right ..correct !?
同样地,我希望这很容易理解,现在小盒子会移到左侧,小盒子的重量是 4.0,所以当重量是 3.5 和 4.5 之间时......
so similarly I hope this is easy to understand now small box is going to the left side and for small box weight is 4.0 so when the weight is 3.5 and between 4.5...
左滚轮将打开,右滚轮将关闭..END_IF。
left roller will be ON and right roller will be OFF ..END_IF.
好吧,这个逻辑说..
Okay so this logic says..
基于我们在滚筒上转动的重量,我们不是直接读取重量。
based on the weight we are turning on the rollers and we are reading not the weight directly..
我们正在读取数据库中的重量..
we are reading the weight which was in our database ..
这也是正确的好吗?
which is also correct okay?
所以让我们尝试一下这个逻辑,我将转到主逻辑......
So let's try this logic I will go to main logic ...
我必须更新我的块,因为我们现在左滚轮和右滚轮有更多输出......
I have to update my block because we have more outputs now left roller and right roller...
在此处检查您的输出“向左发送”是 Q0.2 “向右发送”Q0.3...
check your outputs here 'send left' was Q0.2 'send right' Q0.3...
所以现在我们有了价值观......一切都好......
so now we have the values ...everything is okay...
下载逻辑,您将看到结果。
download the logic and you will see the result.
一切看起来都还好吗?
Everything looks okay?
是的 ?
Yes ?
回去吧,让我们开始吧..
Go back and let's Start ..
所以这是一个向右的中型盒子..
so this is a medium box going towards right..
这是想要的吗!?
was it desired yes!?
中型将向右..
medium is going to right..
较大的是直行,较小的是左侧..
larger is going to straight and smaller is going to left ..
这又是右中号盒子......
this is again right medium box...
这是一个较小的盒子,好吧,所以逻辑是正确的,让我们看看我们是否可以看到内部发生了什么,让我们去……也许是块……因为有时在线上会出现问题……
this is a smaller box alright so a logic is correct let's see if we can see what's happening internally let's go to ...maybe block..as sometimes there is a problem in making it online...
是的 ..
yeah ..
好的?
Okay?
在这里你可以看到比较,如果你不使用整个场景,我希望我可以把它缩小......
Here you can see the comparisons and I hope I can make it small if you're not using the whole scenario...
是的,没关系……现在您可以看到比较结果,结果是正确的……这是一个中等盒子,所以这是真的……
yeah this is okay ...all right now you can see the comparison result which result is true ...this is a medium box so this is true...
为此 - 右侧滚轮已打开,这又是一个中型盒子..
for that - right roller was ON, this is again a medium box ..
这又是真的,现在你可以看到这个盒子的切换,因为重量是可变的。
again this is true and now you can see switching of this boxes because the weight is variable..
你知道,正如我告诉你的那样,体重会增加......
you know as I told you the weight is going to increase...
它将线性增加..
it is going to linearly increase..
这导致了这个变化......所以一个更小的盒子这部分是真的......这部分再次好吧..
which is causing this to vary ...so a smaller box this this part is true ...okay again for this part..
这是真的..向右走...更大的盒子..
this is true ..going to the right ...for larger box..
这是真的,这意味着左滚轮和右滚轮都被重置。
this will be true which means both left and right roller were reset.
所以通过阅读这个监控..
So by reading this monitoring ..
这段代码..
this code..
我们可以了解这里发生了什么,在这里您可以看到存储在临时文件中的值。
we can understand what is happening here and here you can see the values stored in the temporary..
在计数中。
in the count.
所以你可以监控的一切..
So everything you can monitor..
在此监视您的功能代码,在这里您可以看到实际发生的情况?
on this monitoring of your functional code and here you can see the actual happening?
所以这只是第一个食谱?
So this was only the first recipe?
我希望我们刚刚所做的事情并不困难......
I hope it was not difficult what-- we have just did..
只是打开传送带,带一个计数器并在计数器计数的帮助下使用它们,我们显示数据库中的值,然后我们将数据库与一些重量常量进行比较,并根据该常量我们激活和停用滚筒。
was just turning on the conveyors taking a counter and using them with the help of the counts of counter we are showing the value in our database and then we are comparing the database with some constant of the weight and based on that constant we are activating and deactivating the roller.
好吧 ..
Alright ..
现在这个逻辑的第二部分有点复杂,我将在下一个视频中解释,这是如何拥有食谱?
now the second part of this logic is little complicated which I'm going to explain in the next video this was How to have a recipe?
现在在食谱中,如果我想让我的大盒子向左走而不是直走,你可能已经明白了......
Now in the recipe you might have understood if I want my larger box to go left not straight...
这意味着这是较大盒子的条件,如果我想让它向左移动,我必须将 0 更改为 1,将右侧更改为 0。
it means this is the condition for the larger box if I want this to go left I have to change the 0 to 1 and right to 0.
如果我想让我的中型盒子走直,那么我想要这个 0。那么如何根据配方将这个 0-0、0-1、1-0 更改为不同的值,这个想法就是在这里获取变量。
If I want my medium box to go to straight then I want this 0.So how to change this 0-0, 0-1, 1-0 to different value based on the recipe the idea is to take to take the variables here.
根据配方数据应为高和低的布尔变量..
Boolean variables which should be high and low based on the recipe data ..
我们会明白这一点,如果你……的话,这并不那么复杂。
this we are going to understand it's not that complicated if you..
如果您了解数组的基础知识。
if you know basics about arrays.
这并不复杂,所以我们在下一个视频中见,谢谢?
It's not that complicated So I'll see you in the next video thank you?